<?php
/**
 * Created by PhpStorm.
 * User: hiliq
 * Date: 2018/10/5
 * Time: 10:40
 */

namespace app\model;


use think\Model;

class Chapter extends Model
{
    protected $pk='id';

    public function book(){
        return $this->belongsTo('book');
    }

    public function photos(){
        return $this->hasMany('photo');
    }

    public function setChapterNameAttr($value){
        return trim($value);
    }

    // public function save($data = [], $where = [], $sequence = null)
    // {
    //     $num = intval($data['chapter_name']);
    //     if ($num > 10){
    //         $data['isvip'] = 1;
    //     }else{
    //         $data['isvip'] = 0;
    //     }
    //     return parent::save($data, $where, $sequence); // TODO: Change the autogenerated stub
    // }
}